home *** CD-ROM | disk | FTP | other *** search
/ Revista do CD-ROM 101 / CD-ROM 101.iso / compl / maya5ple / Install_MayaPLE5_English.exe / Maya / Data1.cab / performAlign.mel < prev    next >
Encoding:
Text File  |  2003-07-17  |  22.5 KB  |  837 lines

  1. // Copyright (C) 1997-2002 Alias|Wavefront,
  2. // a division of Silicon Graphics Limited.
  3. //
  4. // The information in this file is provided for the exclusive use of the
  5. // licensees of Alias|Wavefront.  Such users have the right to use, modify,
  6. // and incorporate this code into other products for purposes authorized
  7. // by the Alias|Wavefront license agreement, without fee.
  8. //
  9. // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  10. // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
  11. // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  12. // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
  13. // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  14. // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  15. // PERFORMANCE OF THIS SOFTWARE.
  16. //
  17. //
  18. //  Alias|Wavefront Script File
  19. //  MODIFY THIS AT YOUR OWN RISK
  20. //
  21. //  Creation Date:  11 April 1997
  22. //  Author:         mgr
  23. //
  24. //  Description:
  25. //        Initialize the option values for align menu item.
  26. //
  27. //  Input Arguments:
  28. //      int action
  29. //          0 - just execute the align operation
  30. //        1 - show the option box dialog
  31. //          2 - drag to shelf
  32. //
  33. //  Return Value:
  34. //      None.
  35. //
  36.  
  37. proc setOptionVars(int $forceFactorySettings)
  38. {
  39.     //    Attach (on-1 or off-0).
  40.     //
  41.     if ($forceFactorySettings || !`optionVar -exists alignAttach`) {
  42.         optionVar -intValue alignAttach 0;
  43.     }
  44.  
  45.     //    Keep multiple knots (on-1 or off-0 to be used if attach is on).
  46.     //
  47.     if ($forceFactorySettings || !`optionVar -exists alignKeepMultKnots`) {
  48.         optionVar -intValue alignKeepMultKnots 1;
  49.     }
  50.  
  51.     //    Positional continuity type (1-6).
  52.     //
  53.     if ($forceFactorySettings || !`optionVar -exists alignPositionalType`) {
  54.         optionVar -intValue alignPositionalType 1;
  55.     }
  56.  
  57.     //    Tangent continuity (on-1 or off-0).
  58.     //
  59.     if ($forceFactorySettings || !`optionVar -exists alignTangent`) {
  60.         optionVar -intValue alignTangent 1;
  61.     }
  62.  
  63.     //    Tangent continuity type (1-2).
  64.     //
  65.     if ($forceFactorySettings || !`optionVar -exists alignTangentType`) {
  66.         optionVar -intValue alignTangentType 1;
  67.     }
  68.  
  69.     //    Curvature continuity (on-1 or off-0).
  70.     //
  71.     if ($forceFactorySettings || !`optionVar -exists alignCurvature`) {
  72.         optionVar -intValue alignCurvature 0;
  73.     }
  74.  
  75.     //    Tangent scale for object1 (only used if tangent continuity is on).
  76.     //
  77.     if ($forceFactorySettings || !`optionVar -exists alignTangentScale1`) {
  78.         optionVar -floatValue alignTangentScale1 1.0;
  79.     }
  80.  
  81.     //    Tangent scale for object2 (only used if tangent continuity is on).
  82.     //
  83.     if ($forceFactorySettings || !`optionVar -exists alignTangentScale2`) {
  84.         optionVar -floatValue alignTangentScale2 1.0;
  85.     }
  86.  
  87.     //    Curvature scale for object1 (only used if curvature continuity is on).
  88.     //
  89.     if ($forceFactorySettings || !`optionVar -exists alignCurvatureScale1`) {
  90.         optionVar -floatValue alignCurvatureScale1 0.0;
  91.     }
  92.  
  93.     //    Curvature scale for object2 (only used if curvature continuity is on).
  94.     //
  95.     if ($forceFactorySettings || !`optionVar -exists alignCurvatureScale2`) {
  96.         optionVar -floatValue alignCurvatureScale2 0.0;
  97.     }
  98.  
  99.     // keep original (for in place operations is on-1 or off-0).
  100.     //
  101.     if ($forceFactorySettings || !`optionVar -exists alignKeepOriginal`) {
  102.         optionVar -intValue alignKeepOriginal 0;
  103.     }
  104. }
  105.  
  106. //
  107. //  Procedure Name:
  108. //      alignSetup
  109. //
  110. //  Description:
  111. //        Update the state of the option box UI to reflect the align
  112. //        option values.
  113. //
  114. //  Input Arguments:
  115. //      parent               - Top level parent layout of the option box UI.
  116. //                             Required so that UI object names can be 
  117. //                             successfully resolved.
  118. //
  119. //        forceFactorySettings - Whether the option values should be set to
  120. //                             default values.
  121. //
  122. //  Return Value:
  123. //      None.
  124. //
  125. global proc alignSetup( string $parent,
  126.                         int $forceFactorySettings,
  127.                         string $goToTool )
  128. {
  129.     //    Retrieve the option settings
  130.     //
  131.     setOptionVars($forceFactorySettings);
  132.  
  133.     setParent $parent;
  134.  
  135.     //    Query the optionVar's and set the values into the controls.
  136.  
  137.     //    Attach.
  138.     //
  139.     int $doAttach = `optionVar -q alignAttach`;
  140.     checkBoxGrp -e 
  141.         -value1 $doAttach
  142.         alignAttachBox;
  143.  
  144.     //    Keep mult knots (if remove multiple knots then the 2nd button should 
  145.     //  be selected).
  146.     //
  147.     int $keep = `optionVar -q alignKeepMultKnots`;
  148.     if ( $keep == 0 ) $keep = 2;
  149.     radioButtonGrp -e 
  150.         -select $keep
  151.         -enable $doAttach
  152.         alignMultKnotBtn;
  153.  
  154.     //    Continuity type.
  155.     //
  156.     int $contType = 1;
  157.     if ( `optionVar -q alignTangent` ) $contType++;
  158.     if ( `optionVar -q alignCurvature` ) $contType++;
  159.  
  160.     // select the appriate button in the first group
  161.     radioButtonGrp -e -sl $contType alignContinuityBtn;
  162.  
  163.     if ( $contType == 1 )
  164.     {
  165.         // just positional continuity is on
  166.         //
  167.         tabLayout -e -st emptyBlendingTab tangentBlendingTabs; 
  168.         tabLayout -e -st tangentOff_tab tangentOptionTabs;
  169.     }
  170.     else if ( $contType == 2 )
  171.     {
  172.         // positional and tangent continuity is on
  173.         //
  174.         tabLayout -e -st alignScaleOptions tangentBlendingTabs; 
  175.         tabLayout -e -st tangentOn_tab tangentOptionTabs; 
  176.         floatSliderGrp -e -enable false alignCrvScale1Slider; 
  177.         floatSliderGrp -e -enable false alignCrvScale2Slider;    
  178.     }
  179.     else
  180.     {
  181.         // positional, tangent and curvature continuity is on
  182.         //
  183.         tabLayout -e -st alignScaleOptions tangentBlendingTabs; 
  184.         tabLayout -e -st tangentOn_tab tangentOptionTabs; 
  185.         floatSliderGrp -e -enable true alignCrvScale1Slider; 
  186.         floatSliderGrp -e -enable true alignCrvScale2Slider;
  187.     }
  188.  
  189.     // Positional continuity type (values range 1-6).
  190.     //
  191.     int $posType = `optionVar -q alignPositionalType`;
  192.     if ( $posType < 4 )
  193.     {
  194.         // select the appropriate button in the first group
  195.         radioButtonGrp -e
  196.             -select $posType
  197.             alignModPosBtn;
  198.     }
  199.     else
  200.     {
  201.         // select the appropriate button in the second group (from 1 to 3)
  202.         $posType = $posType - 3;
  203.         radioButtonGrp -e
  204.             -select $posType
  205.             alignModBndBtn;
  206.     }
  207.  
  208.     // Tangent continuity type (if not just positional continuity).
  209.     //
  210.     radioButtonGrp -e
  211.         -select `optionVar -q alignTangentType`
  212.         alignModTanBtn;
  213.  
  214.     // Tangent and curvature scale values.
  215.     //
  216.     floatSliderGrp -e
  217.         -value `optionVar -q alignTangentScale1`
  218.         alignTanScale1Slider;
  219.     floatSliderGrp -e
  220.         -value `optionVar -q alignTangentScale2`
  221.         alignTanScale2Slider;
  222.     floatSliderGrp -e
  223.         -value `optionVar -q alignCurvatureScale1`
  224.         alignCrvScale1Slider;
  225.     floatSliderGrp -e
  226.         -value `optionVar -q alignCurvatureScale2`
  227.         alignCrvScale2Slider;
  228.  
  229.     if ( $forceFactorySettings == 1 )
  230.     {
  231.         // reset the floatSliderGrps default range for the slider part
  232.         //
  233.         floatSliderGrp -e 
  234.             -min -5.0 -max 5.0 -fmn -100.0 -fmx 100.0 
  235.             alignTanScale1Slider;
  236.         floatSliderGrp -e 
  237.             -min -5.0 -max 5.0 -fmn -100.0 -fmx 100.0 
  238.             alignTanScale2Slider;
  239.         floatSliderGrp -e 
  240.             -min -5.0 -max 5.0 -fmn -100.0 -fmx 100.0 
  241.             alignCrvScale1Slider;
  242.         floatSliderGrp -e 
  243.             -min -5.0 -max 5.0 -fmn -100.0 -fmx 100.0 
  244.             alignCrvScale2Slider;
  245.     }
  246.  
  247.     // Keep original.
  248.     //
  249.     checkBoxGrp -e 
  250.         -value1 `optionVar -q alignKeepOriginal`
  251.         alignKeepOrigBox;
  252.  
  253.     if( "" != $goToTool ) { 
  254.         checkBoxGrp -e -v1 `scriptCtx -q -euc $goToTool`
  255.           scriptToolExtraWidget;
  256.         checkBoxGrp -e -v2 `scriptCtx -q -lac $goToTool`
  257.           scriptToolExtraWidget;
  258.     }
  259. }
  260.  
  261. global proc alignCurveSetup( string $parent,
  262.                              int $forceFactorySettings,
  263.                              string $goToTool )
  264. {
  265.     alignCurveToolSetup( $forceFactorySettings, $goToTool );
  266.     alignSetup( $parent, $forceFactorySettings, $goToTool );
  267. }
  268.  
  269. global proc alignSurfaceSetup( string $parent,
  270.                              int $forceFactorySettings,
  271.                              string $goToTool )
  272. {
  273.     alignSurfaceToolSetup( $forceFactorySettings, $goToTool );
  274.     alignSetup( $parent, $forceFactorySettings, $goToTool );
  275. }
  276.  
  277. //
  278. //  Procedure Name:
  279. //      alignCallback
  280. //
  281. //  Description:
  282. //        Update the option values with the current state of the option box UI.
  283. //
  284. //  Input Arguments:
  285. //      parent - Top level parent layout of the option box UI.  Required so
  286. //               that UI object names can be successfully resolved.
  287. //
  288. //        doIt   - Whether the command should execute.
  289. //
  290. //  Return Value:
  291. //      None.
  292. //
  293. global proc alignCallback(string $parent, int $doIt, string $goToTool)
  294. {
  295.     setParent $parent;
  296.  
  297.     //    Set the optionVar's from the control values, and then
  298.     //    perform the command.
  299.  
  300.     //    Attach.
  301.     //
  302.     optionVar -intValue alignAttach
  303.         `checkBoxGrp -q -value1 alignAttachBox`;
  304.  
  305.     // Keep mult knots (if remove multiple knots the query will guve 2 as the
  306.     // selected button but we need the value as 0 for remove and 1 for keep).
  307.     //
  308.     int $keep = `radioButtonGrp -q -select alignMultKnotBtn`;
  309.     if ( $keep == 2 ) $keep = 0;
  310.     optionVar -intValue alignKeepMultKnots $keep;
  311.  
  312.     // The continuity types - always have positional continuity at least.
  313.     //
  314.     int $whichPosType = `radioButtonGrp -q -select alignModPosBtn`;
  315.     if ( $whichPosType == 0 ) 
  316.     {
  317.         // a button in the second group was selected so make the optionVar
  318.         // value range 1-6
  319.         //
  320.         $whichPosType = `radioButtonGrp -q -select alignModBndBtn`;
  321.         $whichPosType = $whichPosType + 3;
  322.     }
  323.     optionVar -intValue alignPositionalType $whichPosType;
  324.     int $whichContinuity = `radioButtonGrp -q -select alignContinuityBtn`;
  325.     if ( $whichContinuity == 1 )
  326.     {
  327.         // just have positional continuity
  328.         //
  329.         optionVar -intValue alignTangent 0;
  330.         optionVar -intValue alignCurvature 0;
  331.     }
  332.     else if ( $whichContinuity == 2 )
  333.     {
  334.         // also have tangent continuity
  335.         //
  336.         optionVar -intValue alignTangent 1;
  337.         optionVar -intValue alignCurvature 0;
  338.         int $whichTanType = `radioButtonGrp -q -select alignModTanBtn`;
  339.         optionVar -intValue alignTangentType $whichTanType;
  340.  
  341.         optionVar -floatValue alignTangentScale1
  342.             `floatSliderGrp -q -value alignTanScale1Slider`;
  343.         optionVar -floatValue alignTangentScale2
  344.             `floatSliderGrp -q -value alignTanScale2Slider`;
  345.     }
  346.     else if ( $whichContinuity == 3 )
  347.     {
  348.         // also have tangent and curvature continuity
  349.         //
  350.         optionVar -intValue alignTangent 1;
  351.         optionVar -intValue alignCurvature 1;
  352.         int $whichTanType = `radioButtonGrp -q -select alignModTanBtn`;
  353.         optionVar -intValue alignTangentType $whichTanType;
  354.  
  355.         optionVar -floatValue alignTangentScale1
  356.             `floatSliderGrp -q -value alignTanScale1Slider`;
  357.         optionVar -floatValue alignCurvatureScale1
  358.             `floatSliderGrp -q -value alignCrvScale1Slider`;
  359.         optionVar -floatValue alignTangentScale2
  360.             `floatSliderGrp -q -value alignTanScale2Slider`;
  361.         optionVar -floatValue alignCurvatureScale2
  362.             `floatSliderGrp -q -value alignCrvScale2Slider`;
  363.     }
  364.  
  365.     // Keep original.
  366.     //
  367.     optionVar -intValue alignKeepOriginal 
  368.         `checkBoxGrp -q -value1 alignKeepOrigBox`;
  369.  
  370.     if( 1 == $doIt ) {
  371.         performAlign( 0, "", $goToTool); 
  372.         string $tmpCmd = "performAlign( 0, \"\", \"" + $goToTool + "\")";
  373.         addToRecentCommandQueue $tmpCmd "Align";
  374.     }
  375.     else if ($doIt) {
  376.         setToolTo $goToTool;
  377.     }
  378. }
  379.  
  380. global proc alignCurveCallback(string $parent, int $doIt, string $goToTool)
  381. {
  382.     if( "" != $goToTool ) {
  383.         optionVar -iv alignCurveEuc `scriptCtx -q -euc $goToTool`;
  384.         optionVar -iv alignCurveLac `scriptCtx -q -lac $goToTool`;
  385.     }
  386.     alignCallback( $parent, $doIt, $goToTool );
  387. }
  388.  
  389. global proc alignSurfaceCallback(string $parent, int $doIt, string $goToTool)
  390. {
  391.     if( "" != $goToTool ) {
  392.         optionVar -iv alignSurfaceEuc `scriptCtx -q -euc $goToTool`;
  393.         optionVar -iv alignSurfaceLac `scriptCtx -q -lac $goToTool`;
  394.     }
  395.     alignCallback( $parent, $doIt, $goToTool );
  396. }
  397.  
  398. //
  399. //  Procedure Name:
  400. //      createAlignUI
  401. //
  402. //  Description:
  403. //        Fill the contents of the option box for align command.
  404. //
  405. //  Input Arguments:
  406. //      The name of the parent layout.
  407. //
  408. //  Return Value:
  409. //      None.
  410. //
  411. proc createAlignUI(string $parent, int $inTheTool, string $goToTool)
  412. {
  413.     setParent $parent;
  414.  
  415.     // the attach options
  416.     //
  417.     checkBoxGrp -label ""
  418.         -numberOfCheckBoxes 1
  419.         -label1 "Attach"
  420.         -onCommand1 ("radioButtonGrp -e -enable true alignMultKnotBtn;")
  421.         -offCommand1 ("radioButtonGrp -e -enable false alignMultKnotBtn;")
  422.         alignAttachBox;
  423.  
  424.     // the first time the option box is opened these buttons
  425.     // should be dimmed because attach is off by default
  426.     //
  427.     radioButtonGrp -enable false -label "Multiple Knots"
  428.         -numberOfRadioButtons 2
  429.         -label1 "Keep"
  430.         -label2 "Remove"
  431.         alignMultKnotBtn;
  432.  
  433.     separator;
  434.  
  435.     tabLayout -tabsVisible false positionalOptionTabs;
  436.         columnLayout positionalOn_tab;
  437.             radioButtonGrp
  438.                 -label "Continuity" -nrb 3
  439.                 -label1 "Position"
  440.                 -label2 "Tangent"
  441.                 -label3 "Curvature"
  442.                 -onCommand1 ("tabLayout -e -st emptyBlendingTab " +
  443.                              "tangentBlendingTabs; tabLayout -e -st " +
  444.                              "tangentOff_tab tangentOptionTabs;")
  445.                 -onCommand2 ("tabLayout -e -st alignScaleOptions " +
  446.                              "tangentBlendingTabs; tabLayout -e -st " +
  447.                              "tangentOn_tab tangentOptionTabs; " +
  448.                              "floatSliderGrp -e -enable false " +
  449.                              "alignCrvScale1Slider; floatSliderGrp -e " +
  450.                              "-enable false alignCrvScale2Slider;")
  451.                 -onCommand3 ("tabLayout -e -st alignScaleOptions " +
  452.                              "tangentBlendingTabs; tabLayout -e -st " +
  453.                              "tangentOn_tab tangentOptionTabs; " +
  454.                              "floatSliderGrp -e -enable true " +
  455.                              "alignCrvScale1Slider; floatSliderGrp -e " +
  456.                              "-enable true alignCrvScale2Slider;")
  457.                 alignContinuityBtn;
  458.  
  459.             radioButtonGrp -label "Modify Position"
  460.                 -numberOfRadioButtons 3
  461.                 -label1 "First" -da1 1
  462.                 -label2 "Second" -da2 2
  463.                 -label3 "Both" -da3 3
  464.                 alignModPosBtn;
  465.  
  466.             radioButtonGrp -label "Modify Boundary"
  467.                 -scl alignModPosBtn
  468.                 -numberOfRadioButtons 3
  469.                 -label1 "First" -da1 4
  470.                 -label2 "Second" -da2 5
  471.                 -label3 "Both" -da3 6
  472.                 alignModBndBtn;
  473.         setParent ..;
  474.     setParent ..;
  475.  
  476.     tabLayout -tabsVisible false tangentOptionTabs;
  477.         columnLayout tangentOn_tab;
  478.             radioButtonGrp -label "Modify Tangent"
  479.                 -numberOfRadioButtons 2
  480.                 -label1 "First" -da1 1
  481.                 -label2 "Second" -da2 2
  482.                 alignModTanBtn;
  483.         setParent ..;
  484.         columnLayout tangentOff_tab;
  485.             separator -h 5 -style "none";
  486.         setParent ..;
  487.     setParent ..;
  488.  
  489.     separator;
  490.  
  491.     tabLayout -tabsVisible false tangentBlendingTabs;
  492.         // Scale options
  493.         //
  494.         columnLayout alignScaleOptions;
  495.             floatSliderGrp -label "Tangent Scale First"
  496.                 -field true
  497.                 -min -5.0 
  498.                 -max 5.0
  499.                 -fmn -100.0 
  500.                 -fmx 100.0
  501.                 alignTanScale1Slider;
  502.  
  503.             // the first time the option box is opened this field
  504.             // should be dimmed because curvature is off by default
  505.             //
  506.             floatSliderGrp -enable false -label "Curvature Scale First"
  507.                 -field true
  508.                 -min -5.0 
  509.                 -max 5.0
  510.                 -fmn -100.0 
  511.                 -fmx 100.0
  512.                 alignCrvScale1Slider;
  513.  
  514.             floatSliderGrp -label "Tangent Scale Second"
  515.                 -field true
  516.                 -min -5.0 
  517.                 -max 5.0
  518.                 -fmn -100.0 
  519.                 -fmx 100.0
  520.                 alignTanScale2Slider;
  521.  
  522.             // the first time the option box is opened this field
  523.             // should be dimmed because curvature is off by default
  524.             //
  525.             floatSliderGrp -enable false -label "Curvature Scale Second"
  526.                 -field true
  527.                 -min -5.0 
  528.                 -max 5.0
  529.                 -fmn -100.0 
  530.                 -fmx 100.0
  531.                 alignCrvScale2Slider;
  532.         setParent ..;
  533.  
  534.         // Empty section when tangent/curvature is turned OFF
  535.         //
  536.         columnLayout emptyBlendingTab;
  537.         setParent ..;
  538.     setParent ..;
  539.  
  540.     separator;
  541.  
  542.     // keep original option
  543.     //
  544.     checkBoxGrp -label ""
  545.         -numberOfCheckBoxes 1
  546.         -label1 "Keep Originals"
  547.         alignKeepOrigBox;
  548.  
  549.     if( $inTheTool ) {
  550.         separator;
  551.         checkBoxGrp -ncb 2 -l "Tool Behavior"
  552.           -l1 "Exit on Completion"
  553.           -v1 off
  554.           -on1 ("scriptCtx -e -euc true " + $goToTool)
  555.           -of1 ("scriptCtx -e -euc false " + $goToTool)
  556.  
  557.           -l2 "Auto Completion"
  558.           -v2 on
  559.           -on2 ("scriptCtx -e -lac true " + $goToTool)
  560.           -of2 ("scriptCtx -e -lac false " + $goToTool)
  561.           scriptToolExtraWidget;
  562.     }
  563. }
  564.  
  565. //
  566. //  Procedure Name:
  567. //      alignOptions
  568. //
  569. //  Description:
  570. //        Construct the option box UI.  Involves accessing the standard option
  571. //        box and customizing the UI accordingly.
  572. //
  573. //  Input Arguments:
  574. //      string $objectType: Is this Align Curves or Align Surfaces?
  575. //
  576. //  Return Value:
  577. //      None.
  578. //
  579. proc alignOptions(string $objectType, int $inTheTool, string $goToTool)
  580. {
  581.     //    Name of the command for this option box.
  582.     //
  583.     string $commandName = "align";
  584.  
  585.     //    Build the option box actions.
  586.     //
  587.     string $callback = ($commandName + $objectType + "Callback");
  588.     string $setup = ($commandName + $objectType + "Setup");
  589.  
  590.     global string $gOptionBoxActionToolItem;
  591.     global string $gOptionBoxActionToolItemCB;
  592.     $gOptionBoxActionToolItem = "modelWithToolAlign" + $objectType;
  593.     $gOptionBoxActionToolItemCB = "align" + $objectType + "ToolScript 3";
  594.  
  595.     //  The value returned is the name of the layout to be used as
  596.     //    the parent for the option box UI.
  597.     //
  598.     string $layout = getOptionBox();
  599.     setParent $layout;
  600.     
  601.     //    Any default option box behavior based on the command name is set 
  602.     //    up with this call.
  603.     //
  604.     setOptionBoxCommandName($commandName+$objectType);
  605.  
  606.     //    Activate the default UI template so that the layout of this 
  607.     //    option box is consistent with the layout of the rest of the 
  608.     //    application.
  609.     //
  610.     setUITemplate -pushTemplate DefaultTemplate;
  611.  
  612.     //    Turn on the wait cursor.
  613.     //
  614.     waitCursor -state 1;
  615.  
  616.     tabLayout -scr true -tv false;
  617.     
  618.     string $parent = `columnLayout -adjustableColumn 1`;
  619.  
  620.     //    Create the UI for the tab that is initially visible.
  621.     //
  622.     createAlignUI($parent, $inTheTool, $goToTool);
  623.  
  624.     //    Turn off the wait cursor.
  625.     //
  626.     waitCursor -state 0;
  627.  
  628.     //    Deactivate the default UI template.
  629.     //
  630.     setUITemplate -popTemplate;
  631.  
  632.     //    Attach actions to those buttons that are applicable to the option
  633.     //    box.  Note that the 'Close' button has a default action attached 
  634.     //    to it that will hide the window.  If a a custom action is
  635.     //    attached to the 'Close' button then be sure to call the 'hide the
  636.     //    option box' procedure within the custom action so that the option
  637.     //    box is hidden properly.
  638.  
  639.     //    'Align' button.
  640.     //
  641.     string $applyBtn = getOptionBoxApplyBtn();
  642.     if( $inTheTool ) {
  643.         button -e
  644.           -label "Align Tool"
  645.           -command ($callback + " " + $parent + " 3 \"" + $goToTool + "\"" )
  646.           $applyBtn;
  647.     }
  648.     else {
  649.         button -e
  650.           -label "Align"
  651.           -command ($callback + " " + $parent + " 1 \"" + $goToTool + "\"" )
  652.           $applyBtn;
  653.     }
  654.  
  655.     //    'Save' button.
  656.     //
  657.     string $saveBtn = getOptionBoxSaveBtn();
  658.     button -e 
  659.         -command ($callback + " " + $parent + " 0 \"" +
  660.                   $goToTool + "\"; hideOptionBox")
  661.         $saveBtn;
  662.  
  663.     //    'Reset' button.
  664.     //
  665.     string $resetBtn = getOptionBoxResetBtn();
  666.     button -e 
  667.         -command ($setup + " " + $parent + " 1 \"" + $goToTool + "\"")
  668.         $resetBtn;
  669.  
  670.     //    Set the option box title.
  671.     //
  672.     if( $inTheTool ) {
  673.         setOptionBoxTitle("Align " + $objectType + "s Tool Options");
  674.     }
  675.     else {
  676.         setOptionBoxTitle("Align " + $objectType + "s Options");
  677.     }
  678.  
  679.     //    Customize the 'Help' menu item text.
  680.     //
  681.     if ($objectType == "Curve") {
  682.         setOptionBoxHelpTag( "AlignCurves" );
  683.     } else {
  684.         setOptionBoxHelpTag( "AlignSurfaces" );
  685.     }
  686.  
  687.     //    Set the current values of the option box.
  688.     //
  689.     eval ($setup + " " + $parent + " 0 \"" + $goToTool + "\"");
  690.     
  691.     //    Show the option box.
  692.     //
  693.     showOptionBox();
  694. }
  695.  
  696. //
  697. //  Procedure Name:
  698. //      alignHelp
  699. //
  700. //  Description:
  701. //        Returns a short description about the align command.
  702. //
  703. //  Input Arguments:
  704. //      None.
  705. //
  706. //  Return Value:
  707. //      string.
  708. //
  709. proc string alignHelp()
  710. {
  711.     return 
  712.     "  Command: Align - aligns two curves or surfaces with positional continuity and with optional tangent or curvature continuity.\n" +
  713.     "Selection: two curves or a parameter point on two curves. Or two surfaces or an isoparm on two surfaces.";    
  714. }
  715.  
  716. //
  717. //  Procedure Name:
  718. //      assembleCmd
  719. //
  720. //  Description:
  721. //        Construct the align command that will apply the option box values.
  722. //
  723. //  Input Arguments:
  724. //      None.
  725. //
  726. //  Return Value:
  727. //      The align command string.
  728. //
  729. proc string assembleCmd()
  730. {
  731.     setOptionVars(false);
  732.  
  733.     // get the global history flag value
  734.     int $doHistory = `constructionHistory -q -tgl`;
  735.  
  736.     // is replace original on/off
  737.     int $replaceOriginal = !`optionVar -q alignKeepOriginal`;
  738.     
  739.     // attach related values
  740.     int $attach = `optionVar -q alignAttach`;
  741.     int $keepMultKnots = `optionVar -q alignKeepMultKnots`;
  742.  
  743.     // positional continuity type
  744.     int $positionalContinuityType = `optionVar -q alignPositionalType`;
  745.  
  746.     // tangent continuity related values
  747.     int $doTangentContinuity = `optionVar -q alignTangent`;
  748.     int $tangentContinuityType = `optionVar -q alignTangentType`;
  749.     float $tangentScale1 = `optionVar -q alignTangentScale1`;
  750.     float $tangentScale2 = `optionVar -q alignTangentScale2`;
  751.  
  752.     // curvature continuity related values
  753.     int $doCurvatureContinuity = `optionVar -q alignCurvature`;
  754.     float $curvatureScale1 = `optionVar -q alignCurvatureScale1`;
  755.     float $curvatureScale2 = `optionVar -q alignCurvatureScale2`;
  756.  
  757.     // set up string for preset function call
  758.     string $cmd = "alignPreset";
  759.     $cmd = $cmd + "(" ;
  760.     $cmd = $cmd + $doHistory;
  761.     $cmd = $cmd + ",";
  762.     $cmd = $cmd + $replaceOriginal;
  763.     $cmd = $cmd + ",";
  764.     $cmd = $cmd + $attach;
  765.     $cmd = $cmd + ",";
  766.     $cmd = $cmd + $keepMultKnots;
  767.     $cmd = $cmd + ",";
  768.     $cmd = $cmd + $positionalContinuityType;
  769.     $cmd = $cmd + ",";
  770.     $cmd = $cmd + $doTangentContinuity;
  771.     $cmd = $cmd + ",";
  772.     $cmd = $cmd + $tangentContinuityType;
  773.     $cmd = $cmd + ",";
  774.     $cmd = $cmd + $doCurvatureContinuity;
  775.     $cmd = $cmd + ",";
  776.     $cmd = $cmd + $tangentScale1;
  777.     $cmd = $cmd + ",";
  778.     $cmd = $cmd + $tangentScale2;
  779.     $cmd = $cmd + ",";
  780.     $cmd = $cmd + $curvatureScale1;
  781.     $cmd = $cmd + ",";
  782.     $cmd = $cmd + $curvatureScale2;
  783.     $cmd = $cmd + ")";
  784.  
  785.     return $cmd;
  786. }
  787.  
  788. //
  789. //  Procedure Name:
  790. //      performAlign
  791. //
  792. //  Description:
  793. //        Perform the align command using the corresponding 
  794. //        option values.  This procedure will also show the option box
  795. //        window if necessary as well as construct the command string
  796. //        that will invoke the align command with the current
  797. //        option box values.
  798. //
  799. //  Input Arguments:
  800. //      0 - Execute the command.
  801. //      1 - Show the option box dialog.
  802. //      2 - Return the command.
  803. //
  804. //  Return Value:
  805. //      The align command string.
  806. //
  807. global proc string performAlign( int $action,
  808.                                  string $objectType,
  809.                                  string $goToTool )
  810. {
  811.     int $inTheTool = false;
  812.     if( 3 == $action ) {
  813.         $action = 1;
  814.         $inTheTool = true;
  815.     }
  816.  
  817.     string $cmd = "";
  818.     switch ($action) {
  819.       case 0:
  820.         setOptionVars(false);
  821.         $cmd = `assembleCmd`;
  822.         eval($cmd);
  823.         break;
  824.  
  825.       case 1:
  826.         alignOptions( $objectType, $inTheTool, $goToTool );
  827.         break;
  828.  
  829.       case 2:
  830.       default:
  831.         setOptionVars(false);
  832.         $cmd = `assembleCmd`;
  833.         break;
  834.     }
  835.     return $cmd;
  836. }
  837.